/**
 * Copyright (C) 2013-2014 the original author or authors.
 */
package com.foreveross.bsl.file.storage;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import com.taobao.common.tfs.packet.FileInfo;

/**
 * @description
 * 
 * @author rening, Wangyi
 * @version v1.0
 * 
 * @date 2013-7-16
 * 
 */
public interface FileStorage {

	String saveFile(File file) throws IOException;

	String saveFile(InputStream in) throws IOException;

	String saveFile(String srcFileName, String destFileName, String suffix) throws IOException;

	String saveFile(byte[] data, String destFileName, String suffix) throws IOException;

	String saveLargeFile(String srcFileName, String destFileName, String suffix) throws IOException;

	boolean unlinkFile(String tfsFileName, String tfsSuffix);

	boolean fetchFile(String storedFileName, String suffix, String fetchedFileName) throws IOException;

	boolean fetchFile(String storedFileName, String suffix, OutputStream output) throws IOException;
	
	void destroy();
	
	boolean exists(String storedFileName);
	
	boolean delete(String storedFileName);
	
/*
 * Deprecated methods
 * 
	String saveFile(String localFileName, String tfsFileName, String tfsSuffix, boolean simpleName);
	
	boolean fetchFile(String tfsFileName, String tfsSuffix, long offset, OutputStream output);
	
	String saveFile(String tfsFileName, String tfsSuffix, byte[] data, int offset, int length);

	String saveFile(String tfsFileName, String tfsSuffix, byte[] data, int offset, int length, boolean simpleName);
	
	String saveLargeFile(byte[] data, String tfsFileName, String tfsSuffix, String key);

	String saveLargeFile(String tfsFileName, String tfsSuffix, byte[] data, int offset, int length, String key);
	
	String saveFile(byte[] data, String tfsFileName, String tfsSuffix, boolean simpleName);
	*/

	FileInfo statFile(String tfsFileName, String tfsSuffix);
/**
	boolean hideFile(String tfsFileName, String tfsSuffix, int option);
	
	boolean fetchFile(String tfsFileName, String tfsSuffix, long offset, long length, OutputStream output);

	boolean fetchFileForce(String tfsFileName, String tfsSuffix, String localFileName);

	boolean fetchFileForce(String tfsFileName, String tfsSuffix, OutputStream output);

	boolean fetchFileForce(String tfsFileName, String tfsSuffix, long offset, OutputStream output);

	boolean fetchFileForce(String tfsFileName, String tfsSuffix, long offset, long length, OutputStream output);

	int openWriteFile(String tfsFileName, String tfsSuffix, String key);

	int openReadFile(String tfsFileName, String tfsSuffix);

	int readFile(int fd, byte[] data, int offset, int length);

	int readFile(int fd, long fileOffset, byte[] data, int offset, int length);

	int writeFile(int fd, byte[] data, int offset, int length);

	String closeFile(int fd);
	*/

}
